<template>
  <div>
    <ul class="mvBox">
      <li v-for="item in mvLIst" :key="item.id">
        <div class="imgbox">
          <img :src="item.imgurl" alt="" />
          <div class="bgBox"></div>
        </div>
        <p class="mvName">{{ item.name }}</p>
      </li>
    </ul>
    <div class="pageBox">
      <div class="prev" @click="getData(2)">上一页</div>
      <div class="next" @click="getData(1)">下一页</div>
    </div>
  </div>
</template>

<script>
import { singerMv } from "@/api";
export default {
  data() {
    return {
      hasMore: false,
      mvLIst: [],
      limit: 12,
      page: 1,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData(num) {
      if (num == 2 && this.page == 1) return;
      if (num == 1 && !this.hasMore) return;
      if (num == 2) this.page--;
      if (num == 1) this.page++;
      singerMv({
        id: this.$route.query.id,
        limit: this.limit,
        offset: (this.page - 1) * this.limit,
      }).then((res) => {
        this.hasMore = res.hasMore;
        this.mvLIst = res.mvs;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.mvBox {
  display: flex;
  flex-wrap: wrap;
  margin: 20px 0 0 -29px;
  li {
    width: 137px;
    padding-left: 29px;
    margin-bottom: 40px;
    .imgbox {
      width: 137px;
      height: 103px;
      border: 1px solid #bebebe;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      .bgBox {
        width: 44px;
        height: 44px;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        margin: auto;
        background: url("./../../assets/imges/btnIcon.png") no-repeat -30px -135px;
      }
    }
    .mvName {
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 19px;
      font-size: 14px;
      margin: 8px 0 3px;
      white-space: nowrap;
    }
  }
}
.pageBox {
  margin: 20px 0;
  text-align: center;
  .prev,
  .next {
    display: inline-block;
    margin: 0 10px;
    height: 24px;
    line-height: 24px;
    color: #333;
    text-align: left;
    border: 1px solid #ccc;
  }
  .prev {
    background: url("./../../assets/imges/btnBackground.png") no-repeat 0 -620px;
    padding-left: 22px;
    width: 47px;
  }
  .next {
    width: 57px;
    padding-left: 12px;
    background: url("./../../assets/imges/btnBackground.png") no-repeat -75px -560px;
  }
}
</style>